#include "Evaluate.h"

using namespace std;



Evaluate::Evaluate(CoverageTable *ct)
	:maxFactor(11),table(ct)
{
}

Evaluate::~Evaluate()
{}

double Evaluate::GetPercent(vector<int>& pa)
{
	return table->CalcPercent(pa);
}

void Evaluate::run(vector<vector<int>>& pop, vector<int>& fitVec)
{
	int popsize=pop.size();
	for(int i=0;i<popsize;i++)
	{
		fitVec[i]=EvaluateSingleCase(pop[i]);
	}
}

int Evaluate::EvaluateSingleCase(const vector<int>& singleCase)
{
	int ret=0;
	int size=singleCase.size();
	for(int i=0;i<size-1;i++)
	{
		for(int j=i+1;j<size;j++)
		{
			int row=size*i-(i*(i+1)>>1)+j-i-1;
			int col=singleCase[i]*maxFactor+singleCase[j];
			if(!table->CheckBit(row,col))
				ret++;
		}
	}
	return ret;
}
